﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using YiLe.UI;

namespace YiLe.Views
{
    public partial class ContactDashboardView : DashboardView
    {
        public ContactDashboardView()
        {
            InitializeComponent();
        }

        public override YiLe.UI.FolderView[] GetDefinedViews()
        {
            return new FolderView[] { new FolderView("Northwind Contacts", ApplicationFolder.ContentViewType.DashBoard, "") };

        }

        private void explorerBar_ItemClick(object sender, Janus.Windows.ExplorerBar.ItemEventArgs e)
        {
            switch (e.Item.Key)
            {
                case "NewCustomer":
                    NewItem("Customers");
                    break;
                case "GoToCustomers":
                    GoToFolder("Customers");
                    break;
                case "NewSupplier":
                    NewItem("Suppliers");
                    break;
                case "GoToSuppliers":
                    GoToFolder("Suppliers");
                    break;
                case "NewEmployee":
                    NewItem("Employees");
                    break;
                case "GoToEmployees":
                    GoToFolder("Employees");
                    break;
            }
        }
        private void GoToFolder(string folderName)
        {
            ApplicationFolder folder = null;
            folder = YiLeSystemApp.RootFolder.Find(folderName);
            if (folder != null)
            {
                YiLeSystemApp.MainForm.CurrentFolder = folder;
            }
        }
        private void NewItem(string foldername)
        {
            ApplicationFolder folder = null;
            folder = YiLeSystemApp.RootFolder.Find(foldername);
            if (folder != null)
            {
                folder.AddNew();
            }
        }

        private void ribbon1_CommandClick(object sender, Janus.Windows.Ribbon.CommandEventArgs e)
        {

            switch (e.Command.Key)
            {
                case "rcmdCustomers":
                    GoToFolder("Customers");
                    break;
                case "rcmdSuppliers":
                    GoToFolder("Suppliers");
                    break;
                case "rcmdEmployees":
                    GoToFolder("Employees");
                    break;
            }
        }


    }
}
